<div class="heading">
	<h3><?php echo $judul_tabel; ?></h3>                    

	<div class="resBtnSearch">
		<a href="#"><span class="icon16 icomoon-icon-search-3"></span></a>
	</div>

	<div class="search">

		<form id="searchform" action="search.html">
			<input type="text" id="tipue_search_input" class="top-search" placeholder="Search here ..." />
			<input type="submit" id="tipue_search_button" class="search-btn" value=""/>
		</form>

	</div><!-- End search -->
	
	<ul class="breadcrumb">
		<li>You are here:</li>
		<li>
			<a href="<?php echo base_url(); ?>penggunaan" class="tip" title="Kembali ke List Penggunaan">
				<span class="icon16 icomoon-icon-screen-2"></span>
			</a> 
			<span class="divider">
				<span class="icon16 icomoon-icon-arrow-right-2"></span>
			</span>
		</li>
		<li class="active">Tambah</li>
	</ul>

</div>
<!-- Form Penggunaan Barang-->
<div class="span9">
	   <div class="box" style="margin-top:0px;margin-left: -40px;">

		   <div class="title">

			   <h4>
				   <span class="icon16 icomoon-icon-equalizer-2"></span>
				   <span>Form Pengiriman</span>
			   </h4>
			   
		   </div>
		   <div class="content">
			   <form class="form-horizontal" action="<?php echo base_url(); ?>penggunaan/save/<?php echo $mode; ?>" method="POST">
				   <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">No Surat Jalan</label>
									<input class="span5 mask" id="nosuratjalan" name="nosuratjalan" type="text" readonly/>
								</div>
								<label class="form-label span4" for="normal">Tgl. Surat</label>
								<input class="span2 mask" id="tglsurat" name="tglsurat" type="text" value="<?php echo date('Y-m-d');?>" />
						   </div>
					   </div> 
				   </div>
				   <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">Lokasi</label>
									<input class="span5 mask" id="lokasi" name="lokasi" type="text" />
								</div>
								<label class="form-label span4" for="normal">Tgl. Kirim</label>
								<input class="span2 mask" id="tglkirim" name="tglkirim" type="text" />
						   </div>
					   </div> 
				   </div>
				   <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">Daerah</label>
									<input class="span5 mask" id="daerah" name="daerah" type="text" />
								</div>
								<label class="form-label span4" for="normal">Pembuat</label>
								<input class="span2 mask" id="pembuat" name="pembuat" type="text" />
						   </div>
					   </div> 
				   </div>
				   <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">Request By</label>
									<input class="span8 mask" id="peminta" name="peminta" type="text" />
								</div>
								<label class="form-label span4" for="normal">Pemeriksa</label>
								<input class="span2 mask" id="pemeriksa" name="pemeriksa" type="text" />
						   </div>
					   </div> 
				   </div>
				   <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">Tujuan</label>
									<input class="span8 mask" id="tujuan" name="tujuan" type="text" />
								</div>
								<label class="form-label span4" for="normal">RIG</label>
								<input class="span2 mask" id="rig" name="rig" type="text" />
						   </div>
					   </div> 
				   </div>
				   <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">Alamat</label>
									<input class="span8 mask" id="alamat" name="alamat" type="text" />
								</div>
								<label class="form-label span4" for="normal">Nama Vendor</label>
								<input class="span2 mask" id="namavendor" name="namavendor" type="text" />
						   </div>
					   </div> 
				   </div>
				    <div class="form-row row-fluid">
					   <div class="span12">
						   <div class="row-fluid">
								<div class="span6">
									<label class="form-label span4" for="normal">Negara</label>
									<input class="span5 mask" id="negara" name="negara" type="text" />
								</div>
								<label class="form-label span4" for="normal">Transport</label>
								<input class="span2 mask" id="transportasi" name="transportasi" type="text" />
								
						   </div>
					   </div> 
				   </div>
					<br>
				   <table id="tblDetail" class="responsive table table-bordered">
						<thead>
						  <tr>
							<th>Barang</th>
							<th>Kondisi</th>
							<th>Status</th>
							<th>Keterangan</th>
						  </tr>
						</thead>
						<tbody>
						  
						</tbody>
					</table>
				   <button type="button" class="btn btn-inverse" onclick="addDetail();">Tambah</button>
				   <input type="hidden" id="jmlDetail" name="jmlDetail" value="0">
					<div class="form-actions" align="right">
						<button type="submit" class="btn btn-info">Simpan</button>
						<button type="button" class="btn">Batal</button>
					</div>
					
			   </form>
		   </div>

	   </div><!-- End .box -->

   </div><!-- End .span6 -->
	<script>
		function msgBerhasil(){
			$.pnotify({
				type: 'success',
				title: 'Simpan Data Berhasil',
				icon: 'picon icon16 iconic-icon-check-alt white',
				opacity: 0.95,
				history: false,
				sticker: false
			}); 
		}
		function msgGagal(){
			$.pnotify({
				type: 'error',
				title: 'Simpan Data Gagal!',
				icon: 'picon icon24 typ-icon-cancel white',
				opacity: 0.95,
				history: false,
				sticker: false
			}); 
		}
		$(document).ready(function(){
			<?php
			echo $this->session->flashdata('alert_form');
			?>
			$("#tglsurat,#tglkirim").datepicker({
				showOtherMonths:true,
				dateFormat: "yy-mm-dd"
			});
			$("#nmbarang1").select2();
			generateFaktur();
		});
		
		function getAttrBarang(obj) {
			idx = obj.id.substring(8);
			$.post("<?php echo base_url(); ?>penggunaan/get_attr",{id:obj.value},function(data){
				$arrData = data.split("~");
				$("#kondisi"+idx).val($arrData[0]);
				$("#kdstatus"+idx).val($arrData[1]);
				$("#nmstatus"+idx).val($arrData[2]);
				$("#idbarangdetail"+idx).val(obj.value);
			});
		}
		
		
		function addDetail() {
			var iterat = $("#tblDetail tbody tr").length + 1;
			var html = "<tr>"+
							"<td><input type='hidden' class='span1' id='idbarangdetail"+iterat+"' name='idbarangdetail"+iterat+"' readonly><select name='nmbarang"+iterat+"' id='nmbarang"+iterat+"' class='nostyle' style='width:100%;' onchange='getAttrBarang(this);'></select></td>"+
							"<td width='100'><input type='text' id='kondisi"+iterat+"' name='kondisi"+iterat+"' class='span1' readonly></td>"+
							"<td width='100'><input type='hidden' id='kdstatus"+iterat+"' name='kdstatus"+iterat+"' class='span1' readonly><input type='text' id='nmstatus"+iterat+"' name='nmstatus"+iterat+"' class='span1' readonly></td>"+
							"<td width='100'><input type='text' id='keterangan"+iterat+"' name='keterangan"+iterat+"'></td>"+
						  "</tr>";
			$("#tblDetail tbody").append(html);
			$("#nmbarang"+iterat).html("<?php echo $this->crud->get_combo_barang_keluar(); ?>");
			$("#nmbarang"+iterat).select2();
			$("#nmbarang"+iterat).change();
			$("#keterangan"+iterat).focus();
			$("#jmlDetail").val(parseInt($("#jmlDetail").val())+1);
		}
		function generateFaktur() {
			$.post("<?php echo base_url(); ?>penggunaan/getnomorsj",function(data){
				$("#nosuratjalan").val(data);
			});
		}
	</script>
<!-- END Form Penggunaan Barang-->